﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Comod_DrawPrint3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            ZSql zsql = new ZSql();


            string sql = "select SalesCode,typeStock,comodid,Convert(char(10),C_date,120) as cdate,GuestName,a.WarehouseId,comodName,modul,unit,comodBarcode,prices,number,discount,TotalMoney,a.deptid,realname from CS_Sales a join CS_Guest b on a.guestid=b.guestid join UserInfo c on a.userid=c.userid where typeSale=2 and a.deptid=" + Request.Cookies["user"].Values["deptid"] + "";
            if (!string.IsNullOrEmpty(Request.QueryString["txtdh"]))
            {
                sql += " and SalesCode like'%" + Request.QueryString["txtdh"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request.QueryString["txtSalesCode"]))
            {
                sql += " and modul like'%" + Request.QueryString["txtSalesCode"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request.QueryString["txtGuest"]))
            {
                sql += " and b.GuestName like'%" + Request.QueryString["txtGuest"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request.QueryString["txtKdate"]) && !string.IsNullOrEmpty(Request.QueryString["txtKdate"]))
            {
                sql += " and C_date >='" + Common.FormatParameter(Request.QueryString["txtKdate"]) + " 00:00:00' and C_date<='" + Common.FormatParameter(Request.QueryString["txtKdate"]) + " 23:59:59'";
            }
            //if (HidWareid.Value != "0")
           // {

               // sql += " and warehouse=" + HidWareid.Value;
           // }
            zsql.Open(sql);
            DataTable dt = new DataTable();
            string strTable = "";
            dt = zsql.m_table;

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    strTable += "<div align=\"center\">出库信息</div>";
                    strTable += "<table width=\"100%\" border=\"1\"><tr><td align=\"center\">单号</td><td align=\"center\">开单日期</td><td align=\"center\">库存类型</td> <td align=\"center\">客户名称</td> <td align=\"center\">仓库名</td> <td align=\"center\">商品名称</td><td align=\"center\">型号</td><td align=\"center\">条码</td><td align=\"center\">联系人</td><td align=\"center\">单价(元)</td><td align=\"center\">数量</td><td align=\"center\">单位</td><td align=\"center\">总金额(元)</td></tr>";
                    for (int i = 0; i < zsql.m_table.Rows.Count; i++)
                    {
                        strTable += "<tr><td align=\"center\">" + zsql.m_table.Rows[i]["SalesCode"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["cdate"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["typeStock"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["GuestName"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["WarehouseId"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["comodName"].ToString()+ "</td><td align=\"center\">" + zsql.m_table.Rows[i]["modul"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["comodBarcode"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["prices"].ToString().Substring(0, zsql.m_table.Rows[i]["TotalMoney"].ToString().Length - 2) + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["number"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["unit"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["TotalMoney"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["TotalMoney"].ToString().Substring(0, zsql.m_table.Rows[i]["TotalMoney"].ToString().Length - 2) + "</td></tr>";

                    }
                    strTable += "</table>";//5!1!a!s!p!x
                }
            }
            zsql.Close();

            lblTable.Text = strTable;

        }
    }
}
